load("//bazel:skia_rules.bzl", "skia_cc_library", "skia_filegroup", "split_srcs_and_hdrs")

package(
    default_applicable_licenses = ["//:license"],
)

licenses(["notice"])

skia_filegroup(
    name = "txts",
    srcs = [
        "generated/sksl_compute.minified.sksl",
        "generated/sksl_compute.unoptimized.sksl",
        "generated/sksl_frag.minified.sksl",
        "generated/sksl_frag.unoptimized.sksl",
        "generated/sksl_gpu.minified.sksl",
        "generated/sksl_gpu.unoptimized.sksl",
        "generated/sksl_graphite_frag.minified.sksl",
        "generated/sksl_graphite_frag.unoptimized.sksl",
        "generated/sksl_graphite_vert.minified.sksl",
        "generated/sksl_graphite_vert.unoptimized.sksl",
        "generated/sksl_public.minified.sksl",
        "generated/sksl_public.unoptimized.sksl",
        "generated/sksl_rt_shader.minified.sksl",
        "generated/sksl_rt_shader.unoptimized.sksl",
        "generated/sksl_shared.minified.sksl",
        "generated/sksl_shared.unoptimized.sksl",
        "generated/sksl_vert.minified.sksl",
        "generated/sksl_vert.unoptimized.sksl",
    ],
)

skia_filegroup(
    name = "sksl_data",
    srcs = [
        "sksl_compute.sksl",
        "sksl_frag.sksl",
        "sksl_gpu.sksl",
        "sksl_graphite_frag.sksl",
        "sksl_graphite_vert.sksl",
        "sksl_public.sksl",
        "sksl_rt_shader.sksl",
        "sksl_shared.sksl",
        "sksl_vert.sksl",
    ],
    visibility = ["//tools/sksl-minify:__pkg__"],
)

# Two separate groups, for selecting implementation (and for exporting to sksl.gni)
skia_filegroup(
    name = "sksl_skslc_module_srcs",
    srcs = [
        "SkSLModuleDataFile.cpp",
    ],
    visibility = ["//src/core:__pkg__"],
)

skia_filegroup(
    name = "sksl_default_module_srcs",
    srcs = [
        "SkSLModuleDataDefault.cpp",
    ],
    visibility = ["//src/core:__pkg__"],
)

SKSL_SRCS = [
    "SkSLAnalysis.cpp",
    "SkSLAnalysis.h",
    "SkSLBuiltinTypes.cpp",
    "SkSLBuiltinTypes.h",
    "SkSLCompiler.cpp",
    "SkSLCompiler.h",
    "SkSLConstantFolder.cpp",
    "SkSLConstantFolder.h",
    "SkSLContext.cpp",
    "SkSLContext.h",
    "SkSLDefines.h",
    "SkSLErrorReporter.cpp",
    "SkSLErrorReporter.h",
    "SkSLFileOutputStream.h",
    "SkSLGLSL.h",
    "SkSLInliner.cpp",
    "SkSLInliner.h",
    "SkSLIntrinsicList.cpp",
    "SkSLIntrinsicList.h",
    "SkSLLexer.cpp",
    "SkSLLexer.h",
    "SkSLMangler.cpp",
    "SkSLMangler.h",
    "SkSLMemoryLayout.h",
    "SkSLMemoryPool.h",
    "SkSLModule.cpp",
    "SkSLModule.h",
    "SkSLModuleLoader.cpp",
    "SkSLModuleLoader.h",
    "SkSLOperator.cpp",
    "SkSLOperator.h",
    "SkSLOutputStream.cpp",
    "SkSLOutputStream.h",
    "SkSLParser.cpp",
    "SkSLParser.h",
    "SkSLPool.cpp",
    "SkSLPool.h",
    "SkSLPosition.cpp",
    "SkSLPosition.h",
    "SkSLProgramKind.h",
    "SkSLProgramSettings.h",
    "SkSLSampleUsage.cpp",
    "SkSLString.cpp",
    "SkSLString.h",
    "SkSLStringStream.h",
    "SkSLUtil.cpp",
    "SkSLUtil.h",
    "spirv.h",
]

split_srcs_and_hdrs(
    name = "sksl",
    files = SKSL_SRCS,
)

skia_filegroup(
    name = "gpu_hdrs",
    srcs = [
        "GLSL.std.450.h",
    ],
    visibility = ["//src/sksl/codegen:__pkg__"],
)

skia_filegroup(
    name = "core_srcs",
    srcs = [
        ":sksl_graphite_modules_hdrs",
        ":sksl_srcs",
        "//src/sksl/analysis:analysis_srcs",
        "//src/sksl/ir:ir_srcs",
        "//src/sksl/tracing:core_srcs",
        "//src/sksl/transform:transform_srcs",
    ],
    visibility = ["//src/core:__pkg__"],
)

skia_filegroup(
    name = "core_priv_hdrs",
    srcs = [
        ":sksl_hdrs",
        "//src/sksl/analysis:analysis_hdrs",
        "//src/sksl/ir:ir_hdrs",
        "//src/sksl/tracing:core_priv_hdrs",
        "//src/sksl/transform:transform_hdrs",
    ],
    visibility = ["//src/core:__pkg__"],
)

skia_cc_library(
    name = "generated_sksl",
    textual_hdrs = [":txts"],
    visibility = ["//src/core:__pkg__"],
)

skia_filegroup(
    name = "sksl_graphite_modules_hdrs",
    srcs = [
        "SkSLGraphiteModules.h",
    ],
    visibility = ["//src/gpu/graphite:__pkg__"],
)

skia_filegroup(
    name = "sksl_graphite_modules_srcs",
    srcs = [
        "SkSLGraphiteModules.cpp",
    ],
    visibility = ["//src/gpu/graphite:__pkg__"],
)
